<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
<head>
<head>
<title> 演示实例：倒计时效果-精确到秒 </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<script language="JavaScript">
<!-- //
var overDate = 1000 * 60 * 60 * 24 * 3;//截止时间:为当前计算机时间+3天
var NowTime = new Date();
//var EndTime= new Date(2009,01,11,0,0); 
var EndTime= new Date(NowTime.getTime() + overDate);
var EndTimeMsg = EndTime.getFullYear() + "年";
EndTimeMsg = EndTimeMsg + (EndTime.getMonth()+1) + "月";
EndTimeMsg = EndTimeMsg + (EndTime.getDate()) + "日";
EndTimeMsg = EndTimeMsg + (EndTime.getHours()) + "时";
EndTimeMsg = EndTimeMsg + (EndTime.getMinutes()) + "分";
EndTimeMsg = EndTimeMsg + (EndTime.getSeconds()) + "秒";
function GetRTime(){

	NowTime = new Date();
	var nMS=EndTime.getTime() - NowTime.getTime();
	var nD=Math.floor(nMS/(1000 * 60 * 60 * 24));
	var nH=Math.floor(nMS/(1000*60*60)) % 24;
	var nM=Math.floor(nMS/(1000*60)) % 60;
	var nS=Math.floor(nMS/1000) % 60;
	var nMS=Math.floor(nMS/100) % 10;
	if(nD>= 0){
		document.getElementById("RemainD").innerHTML=nD;
		document.getElementById("RemainH").innerHTML=nH;
		document.getElementById("RemainM").innerHTML=nM;
		document.getElementById("RemainS").innerHTML=nS + "." + nMS;
	}
	else {
		document.getElementById("CountMsg").innerHTML=　EndTimeMsg +"已过！";
	}
	setTimeout("GetRTime()",100);
}
window.onload=function(){
    document.getElementById("EndTimeMsg").innerHTML = EndTimeMsg;
	GetRTime();
}
// -->
</script>
</head>
<body>
<div id="CountMsg">
今天距离
	<strong id="EndTimeMsg">XX</strong>
还有
	<strong id="RemainD">XX</strong>天
	<strong id="RemainH">XX</strong>时
	<strong id="RemainM">XX</strong>分
	<strong id="RemainS">XX</strong>秒
</div>

</body>
</html>